package com.chenfan.mcn.model.dto;

import com.chenfan.mcn.enums.RateCardBasicInfoEnum;
import com.chenfan.mcn.enums.RateCardPlatformInfoEnum;
import com.chenfan.common.extension.validation.groups.Modify;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

/**
 * 刊例配置-新增/修改DTO
 * @Author liuyang
 * @Date 2021/12/30
 * @Time 11:24
 * @Version V1.0
 **/
@Data
public class StarRateCardConfigSaveDTO implements Serializable {

    private static final long serialVersionUID = 5802649576826232719L;

    /**
     * 刊例配置ID
     */
    @NotNull(message = "刊例配置ID不能为空", groups = {Modify.class})
    public Long id;

    /**
     * 刊例平台ID（数字字典）
     */
    @NotBlank(message = "刊例平台不能为空")
    private String platformId;

    /**
     * 刊例平台名称
     */
    @NotBlank(message = "刊例平台不能为空")
    private String platformName;

    /**
     * 基础信息-详见枚举
     */
    @NotEmpty(message = "基础信息不能为空")
    private List<String> basicInfo;

    /**
     * 平台信息-详见枚举
     */
    @NotEmpty(message = "平台信息不能为空")
    private List<String> platformInfo;

    /**
     * 报价方式
     */
    private List<StarQuoteWayDTO> starQuoteWays;


    public List<String> getBasicInfo() {
        if(CollectionUtils.isEmpty(this.basicInfo)) {
            return RateCardBasicInfoEnum.getAutoSelectList();
        }
        return this.basicInfo;
    }

    public List<String> getPlatformInfo() {
        if(CollectionUtils.isEmpty(this.platformInfo)) {
            return RateCardPlatformInfoEnum.getAutoSelectList();
        }
        return platformInfo;
    }
}
